package b;
//p191 LinkedList集合的应用
import java.util.LinkedList;

public class demo2 {
    public static void main(String[] args) {
        LinkedList linkedList = new LinkedList();
        linkedList.add("枕头");
        linkedList.add("被套");
        linkedList.add("床单");
        System.out.print("集合中的元素有：");
        System.out.println(linkedList.toString());
        linkedList.add(2,"毛巾");
        linkedList.addFirst("浴巾");
        linkedList.addLast("浴帽");
        System.out.print("插入元素后，集合中的元素有：");
        System.out.println(linkedList.toString());
        linkedList.remove(4);
        linkedList.removeFirst();
        linkedList.removeLast();
        System.out.print("删除元素后，集合中的元素有：");
        System.out.println(linkedList.toString());
    }
}
